/**
 * 获取合伙人列表
 * @param {*} args
 * @returns
 */
export function get(args) {
  return RSocket.rs({
    route: 'partners',
    args: { ...args },
  });
}

/**
 * 获取合伙人数量
 * @param {*} args
 * @returns
 */
export function count(args) {
  return RSocket.rr({
    route: 'partners.count',
    args: { ...args },
  });
}

/**
 * 创建合伙人
 * @param {*} args
 * @returns
 */
export function create(data) {
  return RSocket.rr({
    route: 'partners.create',
    data: { ...data },
  });
}

/**
 * 删除合伙人
 * @param {*} args
 * @returns
 */
export function deletePartner(username) {
  return RSocket.rr({
    route: `partners.${username}.delete`,
  });
}

/**
 * 更新合伙人
 * @param {*} args
 * @returns
 */
export function update(data) {
  return RSocket.rr({
    route: `partners.${data.username}.update`,
    data: { ...data },
  });
}

/**
 * 更新合伙人状态
 * @param {*} args
 * @returns
 */
export function updateStatus(username, data) {
  return RSocket.rr({
    route: `partners.${username}.update`,
    data: { ...data },
  });
}

/**
 * @description 获取公司
 * @param {*} args 参数
 * @returns array
 */
export function getCompany({ search, pg }) {
  return RSocket.rs({
    route: 'companys',
    args: { search, pg },
  });
}

/**
 * 获取指定用户
 * @param {*} args
 */
export function getUser(username) {
  return RSocket.rr({
    route: `users.${username}`,
  });
}

/**
 * 修改分账接收方账期
 * @param {*} args
 */
export function receiversUpdate(data) {
  return RSocket.rr({
    route: 'pay.receivers.update',
    args: {
      ...data,
    },
  });
}

/* 获取扫码链接 */
export function addProfitShare(type, targetId, period) {
  return RSocket.rr({
    route: 'commons.profit-share-account.bind',
    args: {
      targetType: type,
      targetId,
      period,
    },
  });
}


/**
 * ###后台获取该合伙人团队所有成员业绩信息
 * @returns
 */
export function getGroup({ search, pg }) {
  return RSocket.rs({
    route: 'partners.get.teams.console',
    args: {
      ...search,
      pg,
    },
  });
}

/**
 * ###后台获取该合伙人团队所有成员业绩数量信息
 * @returns
 */
export function getGroupCount({ search }) {
  return RSocket.rr({
    route: 'partners.get.teams.count.console',
    args: {
      ...search,
    },
  });
}

/**
 * ###后台获取该合伙人团队所有成员业绩数量信息
 * @returns
 */
export function getInvite(id) {
  return RSocket.rr({
    route: `users.invite-code.${id}`,
  });
}

/**
 * @func 获取二维码
 */
export function getQCexterior(args) {
  return RSocket.rs({
    route: `wx.${global.getEnvCfg().travel}.post.binary`,
    args: {
      uri: '/wxa/getwxacode',
      body: {
        ...args,
        width: 800,
      },
    },
    binary: true,
  });
}

/**
 * @func 获取字典
 */
export function getDictsItems(dictId) {
  return RSocket.rs({
    route: `dicts.${dictId}.items`,
    args: {
      search: {},
      pg: {
        size: 10,
        page: 0,
      },
    },
  });
}

/**
 * 获取客户信息
 * @param { object }  search pg
 */
// eslint-disable-next-line no-shadow
export function getCustomers(search) {
  return RSocket.rr({
    route: 'customers.count',
    args: {
      ...search,
    },
  });
}

/**
 * @description 获取指定互联网用户
 * @param {*} typeName 字典标识
 * @returns true
 */
export function getCustomerUser(username) {
  return RSocket.rr({
    route: `inetusers.${username}`,
  });
}

export function getCommandCode(data) {
  return RSocket.rr({
    route: 'biz.codes.generate',
    data: {
      ...data,
    },
  });
}

export function getPayTransTotal(args) {
  return RSocket.rr({
    route: 'pay.trans.target-profits.total',
    args: {
      ...args,
    },
  });
}
